#include "MyShellGrammarNode.h"

// 语法节点GrammarNode的构造函数
mysh::GrammarNode::GrammarNode(mysh::GRAMMAR_NODE_TYPE grammar_node_type): 
    grammar_node_type(grammar_node_type)
{
}

// 声明语句节点DeclareStatementNode的构造函数
mysh::DeclareStatementNode::DeclareStatementNode(
    mysh::WORD_TYPE data_type, 
    const std::vector<std::string>& identifiers, 
    const std::int32_t& dimension, 
    const std::vector<std::size_t>& size_of_every_demension): 
    GrammarNode(mysh::GRAMMAR_NODE_TYPE::DECLARE_STATEMENT), 
    data_type(data_type), 
    identifiers(identifiers), 
    dimension(dimension), 
    size_of_every_demension(size_of_every_demension)
{
}

// 运行语句节点RunStatementNode的构造函数
mysh::RunStatementNode::RunStatementNode(
    const std::vector<mysh::Word>& param_list, 
    mysh::WORD_TYPE data_type, 
    const std::int32_t& dimension, 
    const std::vector<std::size_t>& size_of_every_demension, 
    const std::string& command): 
    GrammarNode(mysh::GRAMMAR_NODE_TYPE::RUN_STATEMENT), 
    param_list(param_list), 
    data_type(data_type), 
    dimension(dimension), 
    size_of_every_demension(size_of_every_demension), 
    command(command)
{
}

// 输入输出语句节点InputOutputStatementNode的构造函数
mysh::InputOutputStatementNode::InputOutputStatementNode(
    bool input_output, 
    const std::string& identifier): 
    GrammarNode(input_output ? mysh::GRAMMAR_NODE_TYPE::INPUT_STATEMENT : mysh::GRAMMAR_NODE_TYPE::OUTPUT_STATEMENT), 
    identifier(identifier)
{
}

// 左值节点LeftValueNode的构造函数
mysh::LeftValueNode::LeftValueNode(const std::string& identifier, const std::vector<mysh::Word>& index): 
    GrammarNode(mysh::GRAMMAR_NODE_TYPE::LEFT_VALUE_NODE), 
    identifier(identifier), 
    index(index)
{
}

// 数值节点DataNode的构造函数
mysh::DataNode::DataNode(mysh::WORD_TYPE data_type, const std::string& value): 
    GrammarNode(mysh::GRAMMAR_NODE_TYPE::DATA_NODE), 
    data_type(data_type), 
    value(value)
{
}

// 赋值语句AssignStatementNode的构造函数
mysh::AssignStatementNode::AssignStatementNode(
    const std::shared_ptr<mysh::LeftValueNode>& left_value, 
    const std::shared_ptr<mysh::GrammarNode>& expression): 
    GrammarNode(mysh::GRAMMAR_NODE_TYPE::ASSIGN_STATEMENT), 
    left_value(left_value), 
    expression(expression)
{
}

// if-else语句块IfElseStatementBlock的构造函数
mysh::IfElseStatementBlock::IfElseStatementBlock(
    const std::vector<std::shared_ptr<mysh::GrammarNode>>& conditions, 
    const std::vector<std::vector<std::shared_ptr<mysh::GrammarNode>>>& statements):
    GrammarNode(mysh::GRAMMAR_NODE_TYPE::IF_ELSE_BLOCK), 
    conditions(conditions), 
    statements(statements)
{    
}

// for-to语句块ForToStatementBlock的构造函数
mysh::ForToStatementBlock::ForToStatementBlock(
    const std::shared_ptr<mysh::GrammarNode>& node_before_to, 
    const std::shared_ptr<mysh::GrammarNode>& node_after_to, 
    const std::vector<std::shared_ptr<mysh::GrammarNode>>& statements):
    GrammarNode(mysh::GRAMMAR_NODE_TYPE::FOR_TO_BLOCK), 
    node_before_to(node_before_to), 
    node_after_to(node_after_to), 
    statements(statements)
{
}

// for-in语句块ForInStatementBlock的构造函数
mysh::ForInStatementBlock::ForInStatementBlock(
    const std::shared_ptr<mysh::GrammarNode>& node_before_in, 
    const std::shared_ptr<mysh::GrammarNode>& node_after_in, 
    const std::vector<std::shared_ptr<mysh::GrammarNode>>& statements): 
    GrammarNode(mysh::GRAMMAR_NODE_TYPE::FOR_IN_BLOCK), 
    node_before_in(node_before_in), 
    node_after_in(node_after_in), 
    statements(statements)
{
}